package HelloServiceDo

import (
	"goGrpc/helloService/DataBaseUtils"
	"goGrpc/helloService/Models"
	"goGrpc/helloService/Utils"
	"log"
)

func MyHelloSql() {
	sqlStr := "SELECT * FROM customer"
	var customer []HelloServiceModels.Customer
	log.Println("sql语句", sqlStr)
	if err := DataBaseUtils.MySqlConnection.Ping(); err != nil {
		log.Fatalf("Mysql连接池工作异常！err:%v\n", err)
	}
	if err := DataBaseUtils.MySqlConnection.Select(&customer, sqlStr); err != nil {
		log.Fatalf("获取数据异常！, err:%v\n", err)
	}

	for i := 0; i < len(customer); i++ {
		result := HelloServiceUtils.StructPrint(customer[i], "Customer")
		log.Printf(result)
	}
}
